package cn.wgx.modules.sys.services;

import cn.wgx.modules.base.services.BaseService;
import cn.wgx.modules.sys.entity.mapper .SysMenuUserMapper;
import cn.wgx.modules.sys.entity .SysMenuUser;
import cn.wgx.modules.sys.entity .SysMenuUserExample;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SysMenuUserService extends BaseService<SysMenuUser> {

    @Resource
    SysMenuUserMapper mapper;

    @Transactional(readOnly = true)
    public List<SysMenuUser> getList(SysMenuUser record, Boolean desc) {
		SysMenuUserExample example = new SysMenuUserExample();
		example.setOrderByClause("createDate " + (desc?"desc": "asc"));
		return mapper.selectByExample(example);
    }

    @Transactional(readOnly = true)
    public List<SysMenuUser> getListByIds(List<Integer> ids) {
        if(ids == null || ids.isEmpty()){
            return emptyList;
        }
        List<Integer> uniList = getUniList(ids);
        if(!uniList.isEmpty()){
            SysMenuUserExample example = new SysMenuUserExample();
            SysMenuUserExample.Criteria criteria = example.createCriteria();
            criteria.andMenu_user_idIn(uniList);
            List<SysMenuUser> eduCourseAssignmentHis = mapper.selectByExample(example);
            return eduCourseAssignmentHis;
        }
        return null;
    }


    @Transactional(readOnly = true)
    public SysMenuUser getOne(Integer id) {
		return mapper.selectByPrimaryKey(id);
    }

    @Transactional
    public SysMenuUser insertOne( SysMenuUser record) {
        mapper.insertSelective(record);
        return record;
    }


    @Transactional
    public SysMenuUser updateOne( SysMenuUser record) {
        mapper.updateByPrimaryKeySelective(record);
        return record;

    }


    @Transactional
    public int deleteOne( Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

	

}